<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原生Ajax</title>
</head>
<body>
<input id="btn1" type="button" value="获取数据">

<div id="div1"></div>

<script>
    document.querySelector('#btn1').addEventListener('click', ()=> {
        //1. 创建XMLHttpRequest
        var xmlHttpRequest  = new XMLHttpRequest();

        //2. 发送异步请求
        xmlHttpRequest.open('GET', 'https://mock.apifox.cn/m1/3083103-0-default/emps/list');
        xmlHttpRequest.send();//发送请求

        //3. 获取服务响应数据
        xmlHttpRequest.onreadystatechange = function(){
            if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){
                document.getElementById('div1').innerHTML = xmlHttpRequest.responseText;
            }
        }
    })
</script>
</body>
</html>